const state = {
    a:1,
    b:2,
    num:1
}

const getters = {
    result:(state) => {
        return state.a+state.b
    }
}

const actions = {
    setA({ commit },data) {
        commit('SET_A')
    },
    setB({ commit }) {
        commit('SET_B')
    },
    setNum({commit},key='add'){
        key === 'add' ? commit('ADD_NUM') : commit('CUT_NUM')
    }
}
const mutations = {
    SET_A(state) {
        state.a++
    },
    SET_B(state) {
        state.b++
    },
    ADD_NUM(state) {
        state.num++
    },
    CUT_NUM(state) {
        this.$store
        state.num-- 
    }
}

export default {
    state,
    getters,
    actions,
    mutations
}